﻿<?php
/**
 * danhsach View for danhsach World Component
 * 
 * @package    Joomla.Tutorials
 * @subpackage Components
 * @link http://dev.joomla.org/component/option,com_jd-wiki/Itemid,31/id,tutorials:components/
 * @license		GNU/GPL
 */

jimport( 'joomla.application.component.view');

/**
 * HTML View class for the danhsachWorld Component
 *
 * @package		Joomla.Tutorials
 * @subpackage	Components
 */
class DanhSachViewManage extends JView
{

	function display($tpl = null)
	{
	$danhsach        =& $this->get('Data'); 
    $isNew        = ($danhsach->mads < 1); 
    $text = $isNew ? JText::_( 'New' ) : JText::_( 'Edit' ); 
    JToolBarHelper::title(   JText::_( 'Quản lý danh sách thành viên của nhóm' ).': <small><small>[ ' . $text.' ]</small></small>' ); 
    JToolBarHelper::save(); 
    if ($isNew)  { 
        JToolBarHelper::cancel(); 
    } else { 
        // for existing items the button is renamed `close` 
        JToolBarHelper::cancel( 'cancel', 'Close' ); 
    } 
	
	/*Create list of nganh*/	
		
		$state =& $this->get( 'state' );
		$filter_nganh=$state->get('filter_nganh'); 
			
		$db	=& JFactory::getDBO();
		$query = 'SELECT manganh AS value, tennganh AS text'
			. ' FROM #__nganh'
		;
		$db->setQuery( $query );
		$types[] = JHTML::_('select.option',  '', '- '. JText::_( 'Chọn ngành' ) .' -' );
		foreach( $db->loadObjectList() as $obj )
		{
			$types[] = JHTML::_('select.option',  $obj->value, JText::_( $obj->text ) );
		}
		$lists['type'] 	= JHTML::_('select.genericlist',   $types, 'filter_nganh', 'class="inputbox" size="1" 
		onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_nganh" );
		/* End */	
		
		/*Create list of phan nganh*/
		$filter_chuyennganh=$state->get('filter_chuyennganh');
		
		$where='';
		if($filter_nganh!='')
			$where='where manganh=\''.$filter_nganh.'\'';
		$query = 'SELECT *'
			. ' FROM #__phan_nganh '.$where;
		;
		$db->setQuery( $query );
		$type2[] = JHTML::_('select.option',  '', '- '. JText::_( 'Chọn chyên ngành' ) .' -' );
		foreach( $db->loadObjectList() as $obj )
		{
			$type2[] = JHTML::_('select.option',  $obj->tenphannganh, JText::_( $obj->tenphannganh ) );
		}
		$lists['chuyennganh'] 	= JHTML::_('select.genericlist',   $type2, 'filter_chuyennganh', 'class="inputbox" size="1" 
		onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_chuyennganh" );
		
		/* End */
		
		/*Create list of nhom*/
		$nhom =& $this->get( 'AllNhom');
		$type3[] = JHTML::_('select.option',  '', '- '. JText::_( 'Chọn nhóm' ) .' -' );
		foreach( $nhom as $obj )
		{
			$type3[] = JHTML::_('select.option',  $obj->manhom, JText::_( $obj->tennhom ) );
		}
		$lists['nhom'] 	= JHTML::_('select.genericlist',   $type3, 'manhom', 'class="inputbox" size="1" 
		', 'value', 'text', "$filter_nhom" );
		
		/* End */
		
		/*Create list of sinh vien*/
		$sinhvien =& $this->get( 'AllSinhVien');
		$type4[] = JHTML::_('select.option',  '', '- '. JText::_( 'Chọn sinh viên' ) .' -' );
		foreach( $sinhvien as $obj )
		{
			$type4[] = JHTML::_('select.option',  $obj->masv, JText::_( $obj->tensv ) );
		}
		$lists['sinhvien'] 	= JHTML::_('select.genericlist',   $type4, 'masv', 'class="inputbox" size="1" 
		', 'value', 'text', "$filter_sinhvien" );
		
		/* End */

	$this->assignRef('lists',$lists);
        parent::display($tpl); 
    } 
}
?>